
<?php
include_once("../../untils/conn.php");
// $proxy_id = $_GET['proxy_id'];
$proxy_id = $_POST['proxy_id'];
$state_ban = $_POST['state_ban'];

// echo $proxy_id;

// 查询proxy表中proxy_sta等于$proxy_id的数据
$sql = "SELECT * FROM proxy WHERE proxy_id = $proxy_id";
$result = mysqli_query($con, $sql);

if (mysqli_num_rows($result) > 0) {
  // 如果查询结果存在数据，则进行修改操作
  $row = mysqli_fetch_assoc($result);
  $proxy_sta = $row['proxy_sta'];

  // 判断proxy_sta的值并进行修改
  if ($proxy_sta == 0) {
    $update_sql = "UPDATE proxy SET proxy_sta = 1 WHERE proxy_id = $proxy_id";
  } else {
    $update_sql = "UPDATE proxy SET proxy_sta = 0, state_ban ='$state_ban' WHERE proxy_id = $proxy_id";
  }

  $update_result = mysqli_query($con, $update_sql);

  if ($update_result) {
    echo "<script>alert('操作成功');</script>";
    echo ("<script>window.location.href='../proxylist.php'</script>");
  } else {
    //   echo "Error updating record: " . $con->error;
     echo "<script>alert('操作失败');</script>";
     echo ("<script>window.location.href='../proxylist.php'</script>");
  }
} else {
    //   echo "Error updating record: " . $con->error;
  echo "<script>alert('未查询到相关数据');</script>";
  echo ("<script>window.location.href='../proxylist.php'</script>");
}
?>
